<template>
  <div class="contain">
    <div class="contain-header">
      <el-breadcrumb separator="/">
        <el-breadcrumb-item>数据统计</el-breadcrumb-item>
        <el-breadcrumb-item>医生订单</el-breadcrumb-item>
        <el-breadcrumb-item>收入统计</el-breadcrumb-item>
      </el-breadcrumb>
    </div>
    <div class="contain-body">
      <div class="body-nav">
        <div class="body-header">
          <div class="header-title">医生订单情况</div>
          <el-form :inline="true" size="mini">
            <el-form-item label="订单时间">
              <el-date-picker
                  v-model="page1.orderTime"
                  style="width: 150px"
                  type="date"
                  value-format="yyyy-MM-dd">
              </el-date-picker>
            </el-form-item>
            <el-form-item label="医生">
              <el-select placeholder="请选择医生" v-model="page1.doctorId" clearable>
                <el-option :label="item.realName" :value="item.id" v-for="item in doctorList"
                           :key="item.id"></el-option>
              </el-select>
            </el-form-item>
            <el-form-item>
              <el-button type="primary" icon="el-icon-search" @click="findDoctorOrderStatus">查 询</el-button>
              <el-button type="primary" icon="el-icon-refresh" @click="reset1">刷 新</el-button>
            </el-form-item>
          </el-form>
        </div>
        <div class="body-table">
          <el-table
              :data="tableData1"
              style="width: 100%">
            <el-table-column
                prop="time"
                label="时间"
                align="center"
            >
            </el-table-column>
            <el-table-column
                prop="realName"
                label="医生名称"
                align="center"
            >
            </el-table-column>
            <el-table-column
                prop="totalOrderNum"
                label="订单量总数"
                align="center"
            >
            </el-table-column>
            <el-table-column
                prop="interrogationing"
                label="问诊中订单"
                align="center"
            >
              <template slot-scope="scope">
                {{ scope.row.interrogationing ? scope.row.interrogationing : 0 }}
              </template>
            </el-table-column>
            <el-table-column
                prop="completeOrder"
                label="已完成订单"
                align="center"
            >
              <template slot-scope="scope">
                {{ scope.row.completeOrder ? scope.row.completeOrder : 0 }}
              </template>
            </el-table-column>
          </el-table>
        </div>
        <div class="body-page">
          <el-pagination
              @size-change="handleSizeChange1"
              @current-change="handleCurrentChange1"
              :current-page="page1.pageIndex"
              :page-sizes="[5, 10, 15, 20]"
              :page-size="page1.pageSize"
              layout="total, sizes, prev, pager, next, jumper"
              :total="total1">
          </el-pagination>
        </div>
      </div>

      <div class="body-nav">
        <div class="body-header">
          <div class="header-title">医生收入情况</div>
          <el-form :inline="true" size="mini">
            <el-form-item label="时间">
              <el-date-picker
                  style="width: 300px"
                  type="daterange"
                  clearable
                  range-separator="至"
                  v-model="page2.orderTime"
                  value-format="yyyy-MM-dd"
                  start-placeholder="开始日期"
                  end-placeholder="结束日期">
              </el-date-picker>
            </el-form-item>
            <el-form-item label="医生">
              <el-select placeholder="请选择医生" v-model="page2.doctorId" clearable>
                <el-option :label="item.realName" :value="item.id" v-for="item in doctorList"
                           :key="item.id"></el-option>
              </el-select>
            </el-form-item>
            <el-form-item>
              <el-button type="primary" icon="el-icon-search" @click="findDoctorIncomeStatus">查 询</el-button>
              <el-button type="primary" icon="el-icon-refresh" @click="reset2">刷 新</el-button>
            </el-form-item>
          </el-form>
        </div>
        <div class="body-table">
          <el-table
              :data="tableData2"
              style="width: 100%">
            <el-table-column
                prop="time"
                label="时间"
                align="center"
            >
            </el-table-column>
            <el-table-column
                prop="realName"
                label="医生姓名"
                align="center"
            >
            </el-table-column>
            <el-table-column
                prop="totalOrderNum"
                label="订单总数量"
                align="center"
            >
            </el-table-column>
            <el-table-column
                prop="totalFee"
                label="挂号总收入"
                align="center"
            >
            </el-table-column>
          </el-table>
        </div>
        <div class="body-page">
          <el-pagination
              @size-change="handleSizeChange2"
              @current-change="handleCurrentChange2"
              :current-page="page2.pageIndex"
              :page-sizes="[5, 10, 15, 20]"
              :page-size="page2.pageSize"
              layout="total, sizes, prev, pager, next, jumper"
              :total="total2">
          </el-pagination>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      tableData1: [],
      tableData2:[],
      page1: {
        pageIndex: 1,
        pageSize: 5,
        doctorId: null,
        orderTime: null
      },
      page2: {
        pageIndex: 1,
        pageSize: 5,
        doctorId: null,
        orderTime: []
      },
      total1: 0,
      total2: 0,
      doctorList: []
    }
  },
  created() {
    this.findDoctorOrderStatus()
    this.findDoctorIncomeStatus()
    this.findAllDoctor()
  },
  methods: {
    reset2(){
      this.page2.pageIndex=1
      this.page2.pageSize=5
      this.page2.doctorId=null
      this.page2.orderTime = []
      this.findDoctorIncomeStatus()
    },
    reset1(){
      this.page1.pageIndex=1
      this.page1.pageSize=5
      this.page1.doctorId=null
      this.page1.orderTime = null
      this.findDoctorOrderStatus()
    },
    //订单情况
    findDoctorOrderStatus() {
      this.axios.post('/admin-data-statistics/findDoctorOrderStatus', this.page1).then(res => {
        if (res.data.code === 200) {
          this.tableData1 = res.data.data.data
          this.total1 = res.data.data.total
        }
      })
    },
    //医生收支情况
    findDoctorIncomeStatus() {
      this.axios.post('/admin-data-statistics/findDoctorIncomeStatus', this.page2).then(res => {
        if (res.data.code === 200) {
          this.tableData2 = res.data.data.data
          this.total2 = res.data.data.total
        }
      })
    },
    //查询全部医生
    findAllDoctor() {
      this.axios.post('/admin-doctor/findAll').then(res => {
        if (res.data.code === 200) {
          this.doctorList = res.data.data
        }
      })
    },
    handleSizeChange1(val) {
      this.page1.pageSize = val
      this.findDoctorOrderStatus()
    },
    handleCurrentChange1(val) {
      this.page1.pageIndex = val
      this.findDoctorOrderStatus()
    },
    handleSizeChange2(val) {
      this.page2.pageSize = val
      // this.findDoctorOrderStatus()
    },
    handleCurrentChange2(val) {
      this.page2.pageIndex = val
      // this.findDoctorOrderStatus()
    }
  },
}
</script>

<style scoped lang="less">
.contain {
  width: 100%;
  height: 100%;
  padding-bottom: 20px;
  box-sizing: border-box;
  overflow: auto;
  .contain-header {
    width: 100%;
    height: 50px;
    display: flex;
    align-items: center;
  }
  .contain-body {
    width: 100%;
    overflow: auto;
    .body-nav {
      width: 100%;
      background-color: #ffffff;
      margin-bottom: 20px;
      box-sizing: border-box;
      .body-header {
        width: 100%;
        height: 100px;
        padding: 20px;
        margin-bottom: 10px;
        box-sizing: border-box;

        .header-title {
          font-size: 18px;
          color: #666;
          margin-bottom: 10px;
          font-weight: bold;
        }
      }

      .body-table {
        width: 100%;
        height: calc(100% - 170px);
      }

      .body-page {
        width: 100%;
        height: 70px;
        padding: 20px;
        box-sizing: border-box;
        display: flex;
        align-items: center;
      }
    }

  }
}
</style>
